/**
 * @Author: lifuzhao
 * @Date: 2019-07-11
 * @Project: driver
 */
import md5 from 'js-md5'
import {grades} from "../constant";

export default {
  gradeText(state) {
    let text = ''
    Object.keys(grades).forEach(grade => {
      if (text) return
      if (state.grade === md5(grade)) {
        text = grades[grade]
      }
    })
    return text
  },
  gradeOrigin(state){
    let grade
    let len = Object.keys(grades).length
    for (let i = 1; i <= len; i++){
      let gradeKey = 'grade_' + i
      if(state.grade === md5(gradeKey)){
        grade = i
        break
      }
    }
    return grade
  },
  isDev(){
    return location.hostname === '127.0.0.1' || location.hostname === 'localhost'
  }
}
